package com.microservice.base.task;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

/**
 * @author jbx
 * @package_name com.microservice.base.task
 * @create_date 2020/12/24 9:30
 */
public class Test {
    /**
     * @param: [content]
     * @return: int
     * @description: 十六进制转十进制
     */
    public static int covert(String content){
        int number=0;
        String [] HighLetter = {"A","B","C","D","E","F"};
        Map<String,Integer> map = new HashMap<>();
        for(int i = 0;i <= 9;i++){
            map.put(i+"",i);
        }
        for(int j= 10;j<HighLetter.length+10;j++){
            map.put(HighLetter[j-10],j);
        }
        String[]str = new String[content.length()];
        for(int i = 0; i < str.length; i++){
            str[i] = content.substring(i,i+1);
        }
        for(int i = 0; i < str.length; i++){
            number += map.get(str[i])*Math.pow(16,str.length-1-i);
        }
        return number;
    }
    //测试程序
    public static void main(String... args) {
    System.out.println(new BigInteger("A015DFB2",16).toString());
    }

}
